<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link rel="stylesheet" th:href="@{/layui/css/layui.css}"  media="all">
<style>
	.layui-upload-img {
		max-width: 100%;
	}
	.layui-input-block {
		margin-left: auto;
	}
	.alone {
		width: 89%;
		display: inline-block;
	}
</style>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="layui-form form-horizontal m" id="form-tExam-add">
			<div class="form-group">	
				<label class="col-sm-3 control-label">试卷名称：</label>
				<div class="col-sm-8">
					<input id="eName" name="eName" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">试卷描述：</label>
				<div class="col-sm-8">
					<input id="remark" name="remark" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">试卷状态：</label>
				<div class="col-sm-8">
					<div class="layui-form-item">
						<div class="layui-input-block">
							<input type="radio" name="status" id="status0" value="0" title="开启" checked="">
							<input type="radio" name="status" id="status1" value="1" title="关闭">
						</div>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">组卷规则 ：</label>
				<div class="col-sm-8">
					<div class="layui-form-item">
						<div class="layui-input-block">
							<p>
								选择题：<input id="xnum" name="xnum" type="text" style="width: 30px;">道，每题<input id="xsrore" name="xsrore" type="text" style="width: 30px;">分。
							</p>
							<p>
								判断题：<input id="pnum" name="pnum" type="text" style="width: 30px;">道，每题<input id="psrore" name="psrore" type="text" style="width: 30px;">分。
							</p>
						</div>
					</div>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
	<script th:src="@{/layui/layui.all.js}" charset="utf-8"></script>
    <script type="text/javascript">
		var prefix = ctx + "teach/exam"
		$("#form-tExam-add").validate({
			rules:{
                eName:{
					required:true,
				},
                xnum:{
                    required:true,
                    digits:true
                },
                xcrore:{
                    required:true,
                    digits:true
                },
                pnum:{
                    required:true,
                    digits:true
                },
                pcrore:{
                    required:true,
                    digits:true
                },
			}
		});

		function submitHandler() {
	        if ($.validate.form()) {
                var xnum = $("#xnum").val();
                var xsrore = $("#xsrore").val();
                var pnum = $("#pnum").val();
                var psrore = $("#psrore").val();
                var sumscore = xnum * xsrore + pnum * psrore;
                var msg = confirm("所选题总分为：" + sumscore + " 分，确定要提交吗？ ");
                if(msg) {
                    $.operate.save(prefix + "/add", $('#form-tExam-add').serialize());
				} else {
                    return;
				}
	        }
	    }
	</script>
</body>
</html>
